package com.twittex.view
{
	import com.twittex.TwittexFacade;
	import com.twittex.model.StatusProxy;
	import com.twittex.view.components.FriendsScreen;
	
	import flash.events.TextEvent;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class FriendsScreenMediator extends Mediator
	{
		public static const NAME:String = "FriendsScreenMediator";


		public function FriendsScreenMediator(viewComponent:FriendsScreen) {
			super(NAME, viewComponent);
		}

        override public function listNotificationInterests():Array {
            return [ 
            		TwittexFacade.VIEW_FRIENDS_SCREEN,
					TwittexFacade.FRIEND_STATUSES_FOUND
					];
        }

        override public function handleNotification( note:INotification ):void {
            switch ( note.getName() ) {
				case TwittexFacade.VIEW_FRIENDS_SCREEN:
					//sendNotification(TwittexFacade.FIND_FRIEND_STATUSES);
					var statusProxy:StatusProxy = facade.retrieveProxy(StatusProxy.NAME) as StatusProxy;
					statusProxy.findFriendsStatuses();
					break;
				case TwittexFacade.FRIEND_STATUSES_FOUND:
					friendsScreen.friendStatuses = note.getBody() as Array;
					break;
            }
        }

        protected function get friendsScreen():FriendsScreen {
        	return viewComponent as FriendsScreen;
        }
	}
}